/**
 *  Copyright 2013 Mike Reed
 *
 *  COMP 590 -- Fall 2013
 */

#ifndef GSlide_DEFINED
#define GSlide_DEFINED

#include "GContext.h"

class GSlide {
public:
    typedef GSlide* (*Factory)(void*);

    GSlide();
    virtual ~GSlide();

    virtual void initWithBitmaps(const GBitmap[], int count) {}

    void draw(GContext*);

protected:
    virtual void onDraw(GContext*) = 0;

private:
    struct Rec {
        Rec*    fNext;
        Factory fFact;
        void*   fRefCon;
    };
    static Rec* gHead;

public:
    static void Register(GSlide::Factory, void*);

    class Iter {
    public:
        Iter();
        void reset();
        GSlide* next();
    private:
        Rec*    fHead;
    };

    class Registrar {
    public:
        Registrar(Factory fact, void* refcon = NULL) {
            GSlide::Register(fact, refcon);
        }
    };
};

#endif
